package pers.cj.pdos.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import pers.cj.pdos.cache.CacheData;
import pers.cj.pdos.constant.CacheConstant;
import pers.cj.pdos.entity.Industry;
import pers.cj.pdos.mapper.IndustryMapper;
import pers.cj.pdos.service.IIndustryService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author chenj
 * @since 2019-11-04
 */
@Service
public class IndustryServiceImpl extends ServiceImpl<IndustryMapper, Industry> implements IIndustryService {
    @Autowired
    IndustryMapper industryMapper;

    @Override
    @CacheData(clazz = IndustryServiceImpl.class)
    public List<Industry> listAll() {
        return industryMapper.selectList(null);
    }

    @Override
    @CacheData(clazz = IndustryServiceImpl.class, param = "#id")
    public Industry getById(String id) {
        return industryMapper.selectById(id);
    }

    @Override
    public void insertBatch(List<Industry> list) {
        industryMapper.insertBatch(list);
    }

    @Override
    @CacheData(clazz = IndustryServiceImpl.class, param = "#name")
    public Industry getByName(String name) {
        return industryMapper.selectOne(new QueryWrapper<Industry>().eq("name",name));
    }
}
